<?php

namespace app\common\model;

use think\Db;
use think\Model;

class UserCircle extends Model
{

    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'add_time';
    protected $updateTime = '';
    // 追加属性
    protected $append = ['user_info','cate_name','vehicle_name','address'];

    protected $resultSetType = 'collection';

    public static function get_index_circle($page,$cate_id,$sort_type,$province_id,$city_id,$area_id,$title,$user_id)
    {
        $user_where = "logout = '0' OR logout = '3'";
        $user_id_arr = User::where($user_where)->column("user_id");
        $circle_count = Config::getConfigValue("circle_count"); //首页展示帖子数
        $top_is_show = Config::getConfigValue("top_isshow"); //1显示  0不显示
        $where = "authen = '2'";
        $where.= " AND issale = '1'";
        $where.= " AND isshow_pt = '1'";
        $where.= " AND isshow = '1'";
        if($cate_id){
            $where.= " AND cate_id = {$cate_id}";
        }
        if($user_id_arr){
            $user_id_str = implode(",",$user_id_arr);
            $where.=" AND user_id IN ($user_id_str)";
        }else{
            $user_id_str = 0;
            $where.=" AND user_id IN ($user_id_str)";
        }
        $not_see_arr = Db::name("see")->where("user_id",$user_id)->column("other_id");
        if($not_see_arr){
            $user_id_str = implode(",",$not_see_arr);
            $where.=" AND user_id NOT IN ($user_id_str)";
        }
        $time = time();
        switch ($sort_type) {
            case 1:
                $order = "add_time DESC,top_status ASC,top_time DESC";
                break;
            case 2:
                $order = "top_status ASC,top_time DESC,add_time DESC";
                break;
            case 3:
                $where.= " AND index_top_endtime > '{$time}'";
                $order = "top_status ASC,top_time DESC,add_time DESC";
                break;
            case 4:
                $order = "view DESC,top_status ASC,top_time DESC,add_time DESC";
                break;
            default:
                $order = "top_status ASC,top_time DESC,add_time DESC";
                break;
        }
        if($title){
            $where.= " AND title like '%$title%'";
            $info = Db::name("search_history")->where(["name"=>$title,"user_id"=>$user_id])->find();
            if(!$info){
                $history_data = [];
                $history_data['user_id'] = $user_id;
                $history_data['name'] = $title;
                $history_data['number'] = 1;
                $history_data['add_time'] = time();
                Db::name("search_history")->insert($history_data);
            }else{
                Db::name("search_history")->where(["name"=>$title,"user_id"=>$user_id])->setInc('number',1);
            }
        }
        if($province_id){
            $where.= " AND province_id = {$province_id}";
        }
        if($city_id){
            $where.= " AND city_id = {$city_id}";
        }
        if($area_id){
            $where.= " AND area_id = {$area_id}";
        }
        $field = "id,user_id,cate_id,vehicle_id,province_id,city_id,area_id,title,image,price,collect_count,index_top_time,index_top_endtime,index_top_paytime,if(index_top_endtime > $time,1,2) as top_status ,if(index_top_endtime > $time,index_top_paytime,0) as top_time,is_see,view";
        //$count = self::where($where)->limit($circle_count)->count();
        $count = $circle_count;
        if($page > 1){
            $page = $page + 1;
        }
        $limit = ($page > 1) ? 5 : 10;
        $start = ($page - 1) * $limit;
        $total = ceil($count / $limit);
        if($page == $total){
            $limit = $count - $start;
        }
        if($circle_count == 0){
            $list = [];
        }else{
            $list = self::where($where)->field($field)->order($order)->limit($start, $limit)->select()->toArray();
        }
        foreach ($list as $key=>$value){
            $list[$key]['top_is_show'] = $top_is_show;
            $list[$key]['price'] = format_number($value["price"]);
            $list[$key]['collect_count'] = format_number($value["collect_count"]);
            if($value['index_top_endtime'] > time()){
                $list[$key]['is_top'] = 1;
            }else{
                $list[$key]['is_top'] = 0;
            }
            if ($value['is_see'] == 1 && $value['user_id'] != $user_id) {
                unset($list[$key]);
            }
        }
        // 重新索引数组键
        $list = array_values($list);
        $data = [
            'total'=>$total,
            'list'=>$list
        ];
        return $data;
    }

    public static function get_cate_circle($page,$cate_id,$sort_type,$title,$province_id,$city_id,$area_id,$user_id)
    {
        $user_where = "logout = '0' OR logout = '3'";
        $user_id_arr = User::where($user_where)->column("user_id");
        $top_is_show = Config::getConfigValue("top_isshow"); //1显示  0不显示
        $where = "authen = '2'";
        $where.= " AND issale = '1'";
        $where.= " AND isshow_pt = '1'";
        $where.= " AND isshow = '1'";
        if($cate_id){
            $where.= " AND cate_id = {$cate_id}";
        }
        if($user_id_arr){
            $user_id_str = implode(",",$user_id_arr);
            $where.=" AND user_id IN ($user_id_str)";
        }else{
            $user_id_str = 0;
            $where.=" AND user_id IN ($user_id_str)";
        }
        $not_see_arr = Db::name("see")->where("user_id",$user_id)->column("other_id");
        if($not_see_arr){
            $user_id_str = implode(",",$not_see_arr);
            $where.=" AND user_id NOT IN ($user_id_str)";
        }
        $time = time();
        switch ($sort_type) {
            case 1:
                $order = "add_time DESC,top_status ASC,top_time DESC";
                break;
            case 2:
                $order = "top_status ASC,top_time DESC,add_time DESC";
                break;
            case 3:
                $where.= " AND cate_top_endtime > '{$time}'";
                $order = "top_status ASC,top_time DESC,add_time DESC";
                break;
            case 4:
                $order = "view DESC,top_status ASC,top_time DESC,add_time DESC";
                break;
            default:
                $order = "top_status ASC,top_time DESC,add_time DESC";
                break;
        }
        if($title){
            $where.= " AND title like '%$title%'";
            $info = Db::name("search_history")->where(["name"=>$title,"user_id"=>$user_id])->find();
            if(!$info){
                $history_data = [];
                $history_data['user_id'] = $user_id;
                $history_data['name'] = $title;
                $history_data['number'] = 1;
                $history_data['add_time'] = time();
                Db::name("search_history")->insert($history_data);
            }else{
                Db::name("search_history")->where(["name"=>$title,"user_id"=>$user_id])->setInc('number',1);
            }
        }
        if($province_id){
            $where.= " AND province_id = {$province_id}";
        }
        if($city_id){
            $where.= " AND city_id = {$city_id}";
        }
        if($area_id){
            $where.= " AND area_id = {$area_id}";
        }
        $field = "id,user_id,cate_id,vehicle_id,province_id,city_id,area_id,title,image,price,collect_count,cate_top_time,cate_top_endtime,cate_top_paytime,if(cate_top_endtime > $time,1,2) as top_status ,if(cate_top_endtime > $time,cate_top_paytime,0) as top_time,is_see,view";
        $count = self::where($where)->count();
        if($page > 1){
            $page = $page + 1;
        }
        $limit = ($page > 1) ? 5 : 10;
        $start = ($page - 1) * $limit;
        $total = ceil($count / $limit);
        $list = self::where($where)->field($field)->order($order)->limit($start, $limit)->select()->toArray();
        foreach ($list as $key=>$value){
            $list[$key]['top_is_show'] = $top_is_show;
            $list[$key]['price'] = format_number($value["price"]);
            $list[$key]['collect_count'] = format_number($value["collect_count"]);
            if($value['cate_top_endtime'] > time()){
                $list[$key]['is_top'] = 1;
            }else{
                $list[$key]['is_top'] = 0;
            }
            if ($value['is_see'] == 1 && $value['user_id'] != $user_id) {
                unset($list[$key]);
            }
        }
        // 重新索引数组键
        $list = array_values($list);
        $data = [
            'total'=>$total,
            'list'=>$list
        ];
        return $data;
    }

    public static function get_home_page($page,$is_sale,$user_id,$type,$current_user_id)
    {
        $top_is_show = Config::getConfigValue("top_isshow"); //1显示  0不显示
        if($current_user_id != $user_id){
            $where = "user_id = {$user_id} AND authen != 3";
        }else{
            $where = "user_id = {$user_id}";
        }
        if($is_sale == 3){
            $where.= " AND isshow = '2'";
        }elseif ($is_sale == 4){
            $time = time();
            $where.=" AND (index_top_endtime > '{$time}' OR cate_top_endtime > '{$time}')";
        }elseif(!empty($is_sale)){
            $where.= " AND issale = '{$is_sale}'";
        }
        if($type){
            $where.= " AND authen = '2'";
        }
        $time = time();
        $order = "index_top_endtime DESC,add_time DESC";
        $field = "id,user_id,cate_id,vehicle_id,province_id,city_id,area_id,authen,title,image,price,collect_count,index_top_endtime,cate_top_endtime,view";
        if($current_user_id != $user_id){
            $count = self::where(["user_id"=>$user_id])->where("authen","<>",3)->count();
            $on_sale = self::where(["user_id"=>$user_id,"issale"=>"1"])->where("authen","<>",3)->count();
            $sold = self::where(["user_id"=>$user_id,"issale"=>"2"])->where("authen","<>",3)->count();
            $hidden_number = self::where(["user_id"=>$user_id,"isshow"=>"2"])->where("authen","<>",3)->count();
        }else{
            $count = self::where(["user_id"=>$user_id])->count();
            $on_sale = self::where(["user_id"=>$user_id,"issale"=>"1"])->count();
            $sold = self::where(["user_id"=>$user_id,"issale"=>"2"])->count();
            $hidden_number = self::where(["user_id"=>$user_id,"isshow"=>"2"])->count();
        }
        if($is_sale == 4){
            if($current_user_id != $user_id){
                $top_where = "user_id = {$user_id} AND authen != 3";
            }else{
                $top_where = "user_id = {$user_id}";
            }
            $top_where.=" AND (index_top_endtime > '{$time}' OR cate_top_endtime > '{$time}')";
            $zhiding_number = self::where($top_where)->count();
        }else{
            $zhiding_number = 0;
        }
        if($page > 1){
            $page = $page + 1;
        }
        $limit = ($page > 1) ? 5 : 10;
        $start = ($page - 1) * $limit;
        $total = ceil($count / $limit);
        $list = self::where($where)->field($field)->order($order)->limit($start, $limit)->select()->toArray();
        foreach ($list as &$value){
            $value['top_is_show'] = $top_is_show;
            $value['price'] = format_number($value["price"]);
            $value['collect_count'] = format_number($value["collect_count"]);
            if($value['index_top_endtime'] > $time || $value['cate_top_endtime'] > $time){
                $value['is_top'] = 1;
            }else{
                $value['is_top'] = 0;
            }
        }
        $user_info = self::getUserInfo($user_id);
        $view = UserCircle::where("user_id",$user_id)->sum("view");
        $collect_count = UserCircle::where("user_id",$user_id)->sum("collect_count");
        $user_info["view"] = format_number($view);
        $user_info["collect_count"] = format_number($collect_count);
        $data = [
            'user_info' => $user_info,
            'count' => $count,
            'on_sale'=>$on_sale,
            'sold'=>$sold,
            'hidden_number'=>$hidden_number,
            'zhiding_number'=>$zhiding_number,
            'total'=>$total,
            'list'=>$list
        ];
        return $data;
    }

    public static function get_my_collection($page,$user_id,$is_sale)
    {
        $top_is_show = Config::getConfigValue("top_isshow"); //1显示  0不显示
        $user_where = "logout = '0' OR logout = '3'";
        $user_id_arr = User::where($user_where)->column("user_id");
        $where = "co.user_id = {$user_id}";
        $where.= " AND uc.isshow = '1'";
        $where.= " AND uc.isshow_pt = '1'";
        if($is_sale){
            $where.= " AND uc.issale = '{$is_sale}'";
        }
        $not_see_arr = Db::name("see")->where("user_id",$user_id)->column("other_id");
        if($not_see_arr){
            $user_id_str = implode(",",$not_see_arr);
            $where.=" AND co.other_id NOT IN ($user_id_str)";
        }
        if($user_id_arr){
            $user_id_str = implode(",",$user_id_arr);
            $where.=" AND co.user_id IN ($user_id_str)";
        }else{
            $user_id_str = 0;
            $where.=" AND co.user_id IN ($user_id_str)";
        }
        if($page > 1){
            $page = $page + 1;
        }
        $limit = ($page > 1) ? 5 : 10;
        $start = ($page - 1) * $limit;
        $time = time();
        $order = "uc.index_top_endtime DESC,uc.add_time DESC";
        $field = "uc.id,uc.user_id,uc.cate_id,uc.vehicle_id,uc.province_id,uc.city_id,uc.area_id,uc.authen,uc.title,uc.image,uc.price,uc.collect_count,uc.index_top_endtime,uc.cate_top_endtime,uc.view";
        $num_where = "1=1";
        if($not_see_arr){
            $user_id_str = implode(",",$not_see_arr);
            $num_where.=" AND co.other_id NOT IN ($user_id_str)";
        }
        $all_number = Db::name("collect")->alias("co")->join("user_circle uc","co.circle_id = uc.id")->where(["co.user_id"=>$user_id,"uc.isshow"=>'1',"uc.isshow_pt"=>'1'])->where($num_where)->count();
        $on_sale = Db::name("collect")->alias("co")->join("user_circle uc","co.circle_id = uc.id")->where(["co.user_id"=>$user_id,"uc.issale"=>"1","uc.isshow"=>'1',"uc.isshow_pt"=>'1'])->where($num_where)->count();
        $sold = Db::name("collect")->alias("co")->join("user_circle uc","co.circle_id = uc.id")->where(["co.user_id"=>$user_id,"uc.issale"=>"2","uc.isshow"=>'1',"uc.isshow_pt"=>'1'])->where($num_where)->count();
        $list = Db::name("collect")->alias("co")
            ->join("user_circle uc","co.circle_id = uc.id")
            ->where($where)
            ->field($field)
            ->order($order)
            ->limit($start,$limit)
            ->select();
        foreach ($list as &$value){
            $value['top_is_show'] = $top_is_show;
            $value['price'] = format_number($value["price"]);
            $value['collect_count'] = format_number($value["collect_count"]);
            $value['image'] = splicing_domain($value['image']).'?w=300&h=300';
            if($value['index_top_endtime'] > $time || $value['cate_top_endtime'] > $time){
                $value['is_top'] = 1;
            }else{
                $value['is_top'] = 0;
            }
            $user_info = User::user_info($value['user_id']);
            $value['user_image'] = $user_info['image'];
            $value['username'] = $user_info['username'];
        }
        $data = [
            'all_number' => $all_number,
            'on_sale'=>$on_sale,
            'sold'=>$sold,
            'list'=>$list
        ];
        return $data;
    }

    public static function get_circle_info($id,$user_id)
    {
        $top_is_show = Config::getConfigValue("top_isshow"); //1显示  0不显示
        $field = "id,user_id,cate_id,vehicle_id,title,image,province_id,city_id,area_id,content_images,view,issale,isshow,authen,reason,collect_count,price,base_price,content,index_top_time,index_top_endtime,index_top_price,cate_top_time,cate_top_endtime,cate_top_price,add_time,isshow_pt,pt_reason";
        $info = self::field($field)->find($id);
        if($info['price']){
            $info['price'] = format_number($info["price"]);
        }
        if($info['base_price']){
            $info['base_price'] = format_number($info["base_price"]);
        }
        if($info['view']){
            $info['view'] = format_number($info["view"]);
        }
        if($info['collect_count']){
            $info['collect_count'] = format_number($info["collect_count"]);
        }
        if($info['index_top_endtime'] > time() || $info["cate_top_endtime"] > time()){
            $info['is_top'] = 1;
        }else{
            $info['is_top'] = 0;
        }
        if($info['index_top_time']){
            $info['index_top_time'] = date('Y-m-d H:i:s',$info['index_top_time']);
        }else{
            $info['index_top_time'] = '';
        }
        if($info['index_top_endtime']){
            $info['index_top_endtime'] = '至'.date('Y-m-d H:i:s',$info['index_top_endtime']);
        }else{
            $info['index_top_endtime'] = '';
        }
        if($info['cate_top_time']){
            $info['cate_top_time'] = date('Y-m-d H:i:s',$info['cate_top_time']);
        }else{
            $info['cate_top_time'] = '';
        }
        if($info['cate_top_endtime']){
            $info['cate_top_endtime'] = '至'.date('Y-m-d H:i:s',$info['cate_top_endtime']);
        }else{
            $info['cate_top_endtime'] = '';
        }
        $info["top_isshow"] = $top_is_show;
        $c_where = "circle_id = {$id}";
        $c_where.= " AND user_id = {$user_id}";
        $collect_info = Db::name("collect")->where($c_where)->find();
        if($collect_info){
            $info["is_collection"] = 1;
        }else{
            $info["is_collection"] = 0;
        }
        self::where("id",$id)->setInc('view',1);
        return $info;
    }

    public static function get_circle_share_info($id)
    {
        $top_is_show = Config::getConfigValue("top_isshow"); //1显示  0不显示
        $field = "id,user_id,cate_id,vehicle_id,title,image,province_id,city_id,area_id,content_images,view,issale,isshow,authen,reason,collect_count,price,base_price,content,index_top_time,index_top_endtime,index_top_price,cate_top_time,cate_top_endtime,cate_top_price,add_time,isshow_pt,pt_reason";
        $info = self::field($field)->find($id);
        if($info['price']){
            $info['price'] = format_number($info["price"]);
        }
        if($info['base_price']){
            $info['base_price'] = format_number($info["base_price"]);
        }
        if($info['view']){
            $info['view'] = format_number($info["view"]);
        }
        if($info['collect_count']){
            $info['collect_count'] = format_number($info["collect_count"]);
        }
        if($info['index_top_endtime'] > time() || $info["cate_top_endtime"] > time()){
            $info['is_top'] = 1;
        }else{
            $info['is_top'] = 0;
        }
        if($info['index_top_time']){
            $info['index_top_time'] = date('Y-m-d H:i:s',$info['index_top_time']);
        }else{
            $info['index_top_time'] = '';
        }
        if($info['index_top_endtime']){
            $info['index_top_endtime'] = '至'.date('Y-m-d H:i:s',$info['index_top_endtime']);
        }else{
            $info['index_top_endtime'] = '';
        }
        if($info['cate_top_time']){
            $info['cate_top_time'] = date('Y-m-d H:i:s',$info['cate_top_time']);
        }else{
            $info['cate_top_time'] = '';
        }
        if($info['cate_top_endtime']){
            $info['cate_top_endtime'] = '至'.date('Y-m-d H:i:s',$info['cate_top_endtime']);
        }else{
            $info['cate_top_endtime'] = '';
        }
        $info["top_isshow"] = $top_is_show;
        $info["is_collection"] = 0;
        self::where("id",$id)->setInc('view',1);
        return $info;
    }

    public static function get_circle_msg($id,$user_id)
    {
        $top_is_show = Config::getConfigValue("top_isshow"); //1显示  0不显示
        $field = "id,user_id,cate_id,vehicle_id,title,image,province_id,city_id,area_id,content_images,view,issale,isshow,authen,reason,collect_count,price,base_price,content,index_top,index_top_price,index_top_time,index_top_endtime,index_top_price,cate_top,cate_top_price,cate_top_time,cate_top_endtime,cate_top_price,add_time,isshow_pt,pt_reason";
        $info = self::field($field)->find($id);
        if($info['view']){
            $info['view'] = format_number($info["view"]);
        }
        if($info['collect_count']){
            $info['collect_count'] = format_number($info["collect_count"]);
        }
        if($info['index_top_endtime'] > time() || $info["cate_top_endtime"] > time()){
            $info['is_top'] = 1;
        }else{
            $info['is_top'] = 0;
        }
        if($info['index_top_time']){
            $info['index_top_time'] = date('Y-m-d H:i:s',$info['index_top_time']);
        }else{
            $info['index_top_time'] = '';
        }
        if($info['index_top_endtime']){
            $info['index_top_endtime'] = '至'.date('Y-m-d H:i:s',$info['index_top_endtime']);
        }else{
            $info['index_top_endtime'] = '';
        }
        if($info['cate_top_time']){
            $info['cate_top_time'] = date('Y-m-d H:i:s',$info['cate_top_time']);
        }else{
            $info['cate_top_time'] = '';
        }
        if($info['cate_top_endtime']){
            $info['cate_top_endtime'] = '至'.date('Y-m-d H:i:s',$info['cate_top_endtime']);
        }else{
            $info['cate_top_endtime'] = '';
        }
        $info["top_isshow"] = $top_is_show;
        $c_where = "circle_id = {$id}";
        $c_where.= " AND user_id = {$user_id}";
        $collect_info = Db::name("collect")->where($c_where)->find();
        if($collect_info){
            $info["is_collection"] = 1;
        }else{
            $info["is_collection"] = 0;
        }
        if($info['province_id']){
            $province_name = Area::getAreaName($info['province_id']);
            $info['province_name'] = $province_name;
        }else{
            $info['province_name'] = "";
        }
        if($info['city_id']){
            $city_name = Area::getAreaName($info['city_id']);
            $info['city_name'] = $city_name;
        }else{
            $info['city_name'] = "";
        }
        if($info['area_id']){
            $area_name = Area::getAreaName($info['area_id']);
            $info['area_name'] = $area_name;
        }else{
            $info['area_name'] = "";
        }
        if($info['index_top']){
            $top_info = Db::name("topprice")->where(["type"=>1,"day"=>$info["index_top"]])->find();
            if($top_info){
                $info["index_top"] = $top_info["day"];
                $info["index_top_price"] = $top_info["price"];
            }else{
                $info["index_top"] = "";
                $info["index_top_price"] = "";
            }
        }
        if($info['cate_top']){
            $top_info = Db::name("topprice")->where(["type"=>2,"day"=>$info["cate_top"]])->find();
            if($top_info){
                $info["cate_top"] = $top_info["day"];
                $info["cate_top_price"] = $top_info["price"];
            }else{
                $info["cate_top"] = "";
                $info["cate_top_price"] = "";
            }
        }
        self::where("id",$id)->setInc('view',1);
        return $info;
    }

    public static function circleKeywords()
    {
        $keywords = Db::name('circle_keywords')->column('name');
        return $keywords;
    }

    public static function sensitivewords()
    {
        $sensitivewords = Db::name("sensitivewords")->column('name');
        return $sensitivewords;
    }

    public static function getUserInfo($id)
    {
        $info = User::where("user_id",$id)->field("user_id,username,image,background_image,province,city,authen,authen_time,deposit_price")->find();
        $user_info['user_id'] = $info["user_id"];
        $user_info['username'] = $info["username"];
        $user_info['user_image'] = $info["image"];
        $user_info['province'] = $info["province"];
        $user_info['city'] = $info["city"];
        $user_info['background_image'] = splicing_domain($info["background_image"]);
        $user_info['authen'] = $info["authen"];
        $user_info['deposit_price'] = $info["deposit_price"];
        $user_info['authen_time'] = $info["authen_time"];
        return $user_info;
    }

    //用户信息
    public function getUserInfoAttr($value,$data)
    {
        $info = User::where("user_id",$data["user_id"])->field("user_id,username,image,province,city,authen,authen_time,deposit_price")->find();
        $user_info['user_id'] = $info["user_id"];
        $user_info['username'] = $info["username"];
        $user_info['user_image'] = $info["image"];
        $user_info['province'] = $info["province"];
        $user_info['city'] = $info["city"];
        $user_info['authen'] = $info["authen"];
        $user_info['deposit_price'] = $info["deposit_price"];
        $user_info['authen_time'] = $info["authen_time"];
        return $user_info;
    }

    //车量分类
    public function getCateNameAttr($value,$data)
    {
        if($data['cate_id']){
            $cate_name = Carcategory::where("id",$data['cate_id'])->value("name");
            return $cate_name;
        }else{
            return "";
        }
    }

    //车量类型
    public function getVehicleNameAttr($value,$data)
    {
        if($data['vehicle_id']){
            $vehicle_name = Db::name("vehicle")->where("id",$data['vehicle_id'])->value("name");
            return $vehicle_name;
        }else{
            return "";
        }
    }

    //所在区域
    public function getAddressAttr($value,$data)
    {
        if($data['province_id']){
            $province_name = Area::getAreaName($data['province_id']);
        }else{
            $province_name = "";
        }
        if($data['city_id']){
            $city_name = Area::getAreaName($data['city_id']);
        }else{
            $city_name = "";
        }
        if($data['area_id']){
            $area_name = Area::getAreaName($data['area_id']);
        }else{
            $area_name = "";
        }
        return $province_name.$city_name.$area_name;
    }

    public function getImageAttr($value)
    {
        if($value){
            return splicing_domain($value).'?w=300&h=300';
        }else{
            return "";
        }
    }
    public function getContentImagesAttr($value)
    {
        if($value){
            $images_arr = explode(',',$value);
            foreach ($images_arr as $key=>&$value){
                $value = splicing_domain($value).'?w=600&h=600';
            }
            return $images_arr;
        }else{
            return [];
        }
    }

    public function getAddTimeAttr($value)
    {
        if($value){
            return date("Y-m-d H:i:s",$value);
        }else{
            return "";
        }

    }
}
